class MusicModel {
  final String title;
  final String author;
  final String link;
  final String url;
  final String? pic;
  final String? lrc;
  final String type;
  final int songid;

  const MusicModel({
    required this.title,
    required this.author,
    required this.link,
    required this.url,
    this.pic,
    this.lrc,
    required this.type,
    required this.songid,
  });

  factory MusicModel.fromJson(Map<String, dynamic> json) {
    return MusicModel(
      title: json['title'] ?? '',
      author: json['author'] ?? '',
      link: json['link'] ?? '',
      url: json['url'] ?? '',
      pic: json['pic'],
      lrc: json['lrc'],
      type: json['type'] ?? '',
      songid: json['songid'] ?? 0,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'title': title,
      'author': author,
      'link': link,
      'url': url,
      'pic': pic,
      'lrc': lrc,
      'type': type,
      'songid': songid,
    };
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is MusicModel &&
        other.title == title &&
        other.author == author &&
        other.songid == songid;
  }

  @override
  int get hashCode => title.hashCode ^ author.hashCode ^ songid.hashCode;
}